<?php
$this->meta->css( $this->theme_url . "css/jeans.css",false );
$this->meta->css( _ASSET_URL . "plugins/checkboxtree/jquery.checkboxtree.css",false);
$this->meta->css( _ASSET_URL . "plugins/checkboxtree/library/jquery-ui-1.8.12.custom/css/smoothness/jquery-ui-1.8.12.custom.css",false);

$this->meta->js( _ASSET_URL . "plugins/checkboxtree/library/jquery-1.4.4.js",false);
$this->meta->js( _ASSET_URL . "plugins/checkboxtree/library/jquery-ui-1.8.12.custom/js/jquery-ui-1.8.12.custom.min.js",false);
$this->meta->js( _ASSET_URL . "plugins/checkboxtree/jquery.checkboxtree.min.js",false);
$this->meta->js( $this->theme_url . "js/jquery.easyui.min.js",false);
$group_id = (int)$this->uri->segment(4);
?>
<style type="text/css">
input, label, select, textarea {
	vertical-align:middle !important;	
}
label.label-name {
	padding-left:10px;	
}
</style>
<script type="text/javascript">
$(document).ready(function(){
	
	$('#resourcestree').checkboxTree({ collapseUiIcon: 'ui-icon-plus', expandUiIcon: 'ui-icon-minus', leafUiIcon: '' });
	
	$('#checkall').click(function(){
		$('#resourcestree').checkboxTree('checkAll');
	});	
	
	$('#uncheckall').click(function(){
		 $('#resourcestree').checkboxTree('uncheckAll');
	});
	
	$('#saveaccess').click(function(){
		var postdata = $('#resourcesform').serialize();
		if( typeof(postdata) != 'undefined' || postdata != ''  )
		{
			var url = '<?=site_url('user/groups/save_permission')?>';
			$.ajax({
				url: url,
				data:postdata,
				type:'POST',
				dataType:'json',
				success:function(response){
					if(response.status==1){
						alert(response.msg);	
					}else{
						alert(response.msg,'error');	
					}
				}
			});
		}
		else
		{
			alert('Silahkan pilih resources');	
		}
	});
	
});

</script>

<div style="margin:20px;">

<div class="dialog-button">
<div class="x-linkbutton" id="checkall" iconCls="icon-tick">Checkall</div>
<div class="x-linkbutton" id="uncheckall" iconCls="icon-cross">UnCheckall</div>
<div class="x-linkbutton" id="saveaccess" iconCls="icon-disk">Simpan Akses</div>
</div>
<form method="post" action="" id="resourcesform">
<input type="hidden" name="group_id" value="<?=$group_id?>" />
<?php echo $tree_resources; ?>
</form>


</div>